from django.contrib import admin
from .models import QuestionType,Question,Choice,Answer
# Register your models here.


class ChoiceInline(admin.StackedInline):
    model = Choice
    extra = 3
class AnswerInline(admin.StackedInline):
    model = Answer
    extra = 1
class QuestionTypeAdmin(admin.ModelAdmin):
    fieldsets = [
        #(None,               {'fields': ['question_text']}),
        ('增加问题类型', {'fields': ['question_type']}),
           ]
    #inlines = [ChoiceInline]
    
class QuestionAdmin(admin.ModelAdmin):#为表单选择一个直观的排序方法
    fieldsets = [
        
        #('增加问题类型', {'fields': ['question_type']}),
        ('增加问题', {'fields': ['question_text','question_type']}),
           ]
    inlines = [ChoiceInline,AnswerInline]


    #“更改列表”页面进行一些调整
    list_display = ('question_text',
                    'pub_date',
                    'question_type')



#注册表名到admin进行管理
admin.site.register(QuestionType,QuestionTypeAdmin)
admin.site.register(Question,QuestionAdmin)























